// pages/my/my.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLogin:false,
    oneList:[
      {
        num:0,
        name:"收藏的店铺"
      },
      {
        num:0,
        name:"收藏的商品"
      },
      {
        num:0,
        name:"关注的商品"
      },
      {
        num:0,
        name:"我的足迹"
      },
    ],
    twoList:[
      {
        img:"../../image/money.png",
        name:"我的订单"
      },
      {
        img:"../../image/pay.png",
        name:"待付款"
      },
      {
        img:"../../image/revece.png",
        name:"待收货"
      },
      {
        img:"../../image/payback.png",
        name:"退货/退款"
      }
    ],
    threeList:[
      {
        name:"联系客服"
      },{
        name:"意见反馈"
      },{
        name:"关于我们"
      },{
        name:"设置"
      },
    ],
    userInfo:{}
  },
  // 点击登录
  getUserInfo(e){
console.log(e);
let obj={
  url:e.detail.userInfo.avatarUrl,
  name:e.detail.userInfo.nickName
}
wx.setStorageSync('userInfo', obj)
this.setData({
  userInfo:obj,
  isLogin:true
})
  },
  



  isLogin(){
let userInfo=wx.getStorageSync('userInfo') || ''
if(userInfo){
  this.setData({
    userInfo,
    isLogin:true
  })
}else{
  this.setData({
    userInfo:{},
    isLogin:false
  })
}
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
this.isLogin()
  },
  loginout(e){
    let index = e.currentTarget.dataset.index
    if(index==3){
wx.showModal({
  title: '提示',
  content:'您确定退出登录吗',
  success:(res) =>{
    if(res.confirm){
wx.showToast({
  title: '成功退出登录',
  icon:'success'
})
wx.removeStorageSync('userInfo')
this.isLogin()
    }else if(res.cancel){
      wx.showToast({
        title: '取消退出登录',
        icon:'none'
      })
    }
  }

})

    }
  }
})